﻿@inject Microsoft.Extensions.Localization.IStringLocalizer<RoleModal> _localizer

<EditForm Model="@RoleModel" OnValidSubmit="SaveAsync">
    <FluentValidationValidator @ref="_fluentValidationValidator" />
    <MudDialog>
        <TitleContent>
            @{
                if (RoleModel.Id == null)
                {
                    <MudText Typo="Typo.h6">
                        <MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-3 mb-n1" />
                        @_localizer["Add Role"]
                    </MudText>
                }
                else
                {
                    <MudText Typo="Typo.h6">
                        <MudIcon Icon="@Icons.Material.Filled.Update" Class="mr-3 mb-n1" />
                        @_localizer["Update Role"]
                    </MudText>
                }
            }
        </TitleContent>
        <DialogContent>
            <MudTextField For="@(() => RoleModel.Id)" @bind-Value="RoleModel.Id" Label="@_localizer["Role ID"]" Disabled />
            <MudTextField For="@(() => RoleModel.Name)" @bind-Value="RoleModel.Name" Label="@_localizer["Role Name"]" />
            <MudTextField For="@(() => RoleModel.Description)" @bind-Value="RoleModel.Description" Label="@_localizer["Description"]" />
        </DialogContent>
        <DialogActions>
            <MudButton Variant="Variant.Filled" OnClick="Cancel">@_localizer["Cancel"]</MudButton>
            @{
                if (RoleModel.Id == null)
                {
                    <MudButton Variant="Variant.Filled" ButtonType="ButtonType.Submit" Disabled="@(!Validated)" Color="Color.Success">@_localizer["Save Role"]</MudButton>
                }
                else
                {
                    <MudButton Variant="Variant.Filled" ButtonType="ButtonType.Submit" Disabled="@(!Validated)" Color="Color.Secondary">@_localizer["Update Role"]</MudButton>
                }
            }
        </DialogActions>
    </MudDialog>
</EditForm>